//
// MyGame.cpp for bomberman in /home/lefebv_w//workspace/cpp/bomberman/tests/compil
// 
// Made by damien lefebvre
// Login   <lefebv_w@epitech.net>
// 
// Started on  Thu May  2 18:10:51 2013 damien lefebvre
// Last update Fri May  3 12:18:22 2013 damien lefebvre
//

#include		"MyGame.hh"

void MyGame::initialize(void)
{
  // opengl context & camera
  window_.create();
  m_camera.initialize();

  // objects
  m_objects.push_back(new Model::Bomberman());
  std::list<AObject*>::iterator itb = this->m_objects.begin();
  for (; itb != this->m_objects.end(); ++itb)
    (*itb)->initialize();
}

void MyGame::update(void)
{
  // objects
  std::list<AObject*>::iterator itb = this->m_objects.begin();
  for (; itb != this->m_objects.end(); ++itb)
    (*itb)->update(gameClock_, input_);
  
  // camera
  m_camera.update(gameClock_, input_);
}

void MyGame::draw(void)
{
  // clean buffers
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glClearColor(0.74f, 0.84f, 95.0f, 1.0f);
  glClearDepth(1.0f);

  // objects
  std::list<AObject*>::iterator itb = this->m_objects.begin();
  for (; itb != this->m_objects.end(); ++itb)
    (*itb)->draw();

  // display
  this->window_.display();
}

void MyGame::unload(void)
{}
